package Tables;

import java.sql.*;
import java.util.List;

public class Class extends Table{
    private int id;
    private int number;
    private String counsellor_name;

    public Class(Connection connection) {
        super(connection);
    }
    @Override
    public String toString() {
        return "Class{" +
                "id=" + id +
                ", number=" + number +
                ", counsellor_name='" + counsellor_name + '\'' +
                '}';
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public String getCounsellor_name() {
        return counsellor_name;
    }

    public void setCounsellor_name(String counsellor_name) {
        this.counsellor_name = counsellor_name;
    }

    @Override
    public List<String> get() throws SQLException {
        String order = "select * from class";
        PreparedStatement statement = this.connection.prepareStatement(order);
        ResultSet set = statement.executeQuery();
        while(set.next()){
            this.id = set.getInt(1);
            this.number = set.getInt(2);
            this.counsellor_name = set.getString(3);
            this.tableList.add(toString());
        }
        return this.tableList;
    }
}
